const { Users } = require('../../model/user')

module.exports = async(req, res) => {
    req.app.locals.currentLink = 'user';

    let page = req.query.page || 1;

    let count = await Users.countDocuments({});


    let pagesize = 10;
    let total = Math.ceil(count / pagesize);
    let start = (page - 1) * pagesize

    let users = await Users.find().limit(10).skip(start);
    res.render('./admin/user', {

        users: users,
        total: total,
        count: count,
        page: page
    })
}